#ifndef __S_VECTOR_HH__
#define __S_VECTOR_HH__

#include <vector>
using namespace std;

template <class S_VECTOR_CLASS>
class SVectorIndex
{
public:
  enum { WRONG_S_VECTOR_IDX = 0 };
  SVectorIndex() { index = WRONG_S_VECTOR_IDX; }
  int get_index__() const { return index; }
  void set_index__(int index) { this->index = index; }
  void inc_index__() { this->index++; }
  bool is_good() const { return index != WRONG_S_VECTOR_IDX; }
private:
  int index;
};

template <class S_VECTOR_INDEX>
bool operator==(S_VECTOR_INDEX l, S_VECTOR_INDEX r) {
  return l.get_index__() == r.get_index__();
}

template <class S_VECTOR_INDEX>
bool operator!=(S_VECTOR_INDEX l, S_VECTOR_INDEX r) {
  return l.get_index__() != r.get_index__();
}

template <class S_VECTOR_INDEX>
void advance(S_VECTOR_INDEX* index) {  
  index->inc_index__();
}

template <class INDEX_T_, class V>
class SVector
{
public:
  typedef INDEX_T_ INDEX_T;
  SVector() { data.resize(1); }
  void push_back(const V& v) { data.push_back(v); }

  const V& get_at(INDEX_T i) const { return data[i.get_index__()]; }
  void set_at(INDEX_T i, const V& value) { data[i.get_index__()] = value; }

  INDEX_T begin() const {
    INDEX_T ret;
    ret.set_index__(1);
    return ret;
  }

  INDEX_T end() const {
    INDEX_T ret;
    ret.set_index__(data.size());
    return ret;
  }
private:
  vector<V> data;
};

#endif
